home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 February (DVD) / PCWorld_2008-02_DVD.iso / v cisle / PHP / PHP.exe / EasyPHP-2.0b1-setup.exe / {app} / phpmyadmin / pdf_pages.php < prev    next >
Encoding:
PHP Script  |  2006-11-18  |  26.7 KB  |  570 lines

  1. <?php
  2. /* $Id: pdf_pages.php 9201 2006-07-27 13:34:49Z lem9 $ */
  3. // vim: expandtab sw=4 ts=4 sts=4:
  4.  
  5. /**
  6.  * Gets some core libraries
  7.  */
  8. require_once('./libraries/common.lib.php');
  9. require_once('./libraries/db_details_common.inc.php');
  10.  
  11.  
  12. /**
  13.  * Settings for relation stuff
  14.  */
  15. require_once('./libraries/relation.lib.php');
  16. $cfgRelation = PMA_getRelationsParam();
  17.  
  18. // This is to avoid "Command out of sync" errors. Before switching this to
  19. // a value of 0 (for MYSQLI_USE_RESULT), please check the logic
  20. // to free results wherever needed.
  21. $query_default_option = PMA_DBI_QUERY_STORE;
  22.  
  23. /**
  24.  * Now in ./libraries/relation.lib.php we check for all tables
  25.  * that we need, but if we don't find them we are quiet about it
  26.  * so people can work without.
  27.  * This page is absolutely useless if you didn't set up your tables
  28.  * correctly, so it is a good place to see which tables we can and
  29.  * complain ;-)
  30.  */
  31. if (!$cfgRelation['relwork']) {
  32.     echo sprintf($strNotSet, 'relation', 'config.inc.php') . '<br />' . "\n"
  33.          . '<a href="./Documentation.html#relation" target="documentation">' . $strDocu . '</a>' . "\n";
  34.     require_once('./libraries/footer.inc.php');
  35. }
  36.  
  37. if (!$cfgRelation['displaywork']) {
  38.     echo sprintf($strNotSet, 'table_info', 'config.inc.php') . '<br />' . "\n"
  39.          . '<a href="./Documentation.html#table_info" target="documentation">' . $strDocu . '</a>' . "\n";
  40.     require_once('./libraries/footer.inc.php');
  41. }
  42.  
  43. if (!isset($cfgRelation['table_coords'])){
  44.     echo sprintf($strNotSet, 'table_coords', 'config.inc.php') . '<br />' . "\n"
  45.          . '<a href="./Documentation.html#table_coords" target="documentation">' . $strDocu . '</a>' . "\n";
  46.     exit();
  47. }
  48. if (!isset($cfgRelation['pdf_pages'])) {
  49.     echo sprintf($strNotSet, 'pdf_page', 'config.inc.php') . '<br />' . "\n"
  50.          . '<a href="./Documentation.html#pdf_pages" target="documentation">' . $strDocu . '</a>' . "\n";
  51.     exit();
  52. }
  53.  
  54. if ($cfgRelation['pdfwork']) {
  55.     // Now is the time to work on all changes
  56.     if (isset($do)) {
  57.         switch ($do) {
  58.             case 'choosepage':
  59.                 if ($action_choose=="1") {
  60.                     $ch_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
  61.                               .   ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
  62.                               .   ' AND   pdf_page_number = ' . $chpage;
  63.                     PMA_query_as_cu($ch_query, FALSE, $query_default_option);
  64.  
  65.                     $ch_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages'])
  66.                               .   ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
  67.                               .   ' AND   page_nr = ' . $chpage;
  68.                     PMA_query_as_cu($ch_query, FALSE, $query_default_option);
  69.  
  70.                     unset($chpage);
  71.                 }
  72.                 break;
  73.             case 'createpage':
  74.                 if (!isset($newpage) || $newpage == '') {
  75.                     $newpage = $strNoDescription;
  76.                 }
  77.                 $ins_query   = 'INSERT INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages'])
  78.                              . ' (db_name, page_descr)'
  79.                              . ' VALUES (\'' . PMA_sqlAddslashes($db) . '\', \'' . PMA_sqlAddslashes($newpage) . '\')';
  80.                 PMA_query_as_cu($ins_query, FALSE, $query_default_option);
  81.  
  82.                 // A u t o m a t i c    l a y o u t
  83.                 // ================================
  84.                 if (isset($auto_layout_internal) || isset($auto_layout_innodb)) {
  85.                     // save the page number
  86.                     $pdf_page_number = PMA_DBI_insert_id((isset($controllink)?$controllink:''));
  87.                     $all_tables = array();
  88.                 }
  89.               
  90.                 if (isset($auto_layout_innodb)) {
  91.                     // get the tables list
  92.                     $tables = PMA_DBI_get_tables_full($db);
  93.                     // find the InnoDB ones
  94.                     $innodb_tables = array();
  95.                     foreach($tables as $table_name => $table_properties) {
  96.                         if ($table_properties['ENGINE'] == 'InnoDB') {
  97.                             $innodb_tables[] = $table_name;
  98.                         }
  99.                     }
  100.                     $all_tables = $innodb_tables;
  101.                     // could be improved by finding the tables which have the
  102.                     // most references keys and place them at the beginning
  103.                     // of the array (so that they are all center of schema)
  104.                     unset($tables, $innodb_tables);
  105.                 } // endif auto_layout_innodb
  106.  
  107.                 if (isset($auto_layout_internal)) {
  108.                     // get the tables that have relations, by descending
  109.                     // number of links
  110.                     $master_tables = 'SELECT COUNT(master_table), master_table'
  111.                                 . ' FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation'])
  112.                                 . ' WHERE master_db = \'' . $db . '\''
  113.                                 . ' GROUP BY master_table'
  114.                                 . ' ORDER BY ' . PMA_backquote('COUNT(master_table)') . ' DESC ';
  115.                     $master_tables_rs = PMA_query_as_cu($master_tables, FALSE, $query_default_option);
  116.                     if ($master_tables_rs && PMA_DBI_num_rows($master_tables_rs) > 0) {
  117.                         // first put all the master tables at beginning
  118.                         // of the list, so they are near the center of
  119.                         // the schema
  120.                         while (list(, $master_table) = PMA_DBI_fetch_row($master_tables_rs)) {
  121.                             $all_tables[] = $master_table;
  122.                         }
  123.  
  124.                         // then for each master, add its foreigns into an array
  125.                         // of foreign tables, if not already there
  126.                         // (a foreign might be foreign for more than
  127.                         // one table, and might be a master itself)
  128.  
  129.                         $foreign_tables = array();
  130.                         foreach ($all_tables AS $master_table) {
  131.                             $foreigners = PMA_getForeigners($db, $master_table);
  132.                             foreach ($foreigners AS $foreigner) {
  133.                                 if (!in_array($foreigner['foreign_table'], $foreign_tables)) {
  134.                                     $foreign_tables[] = $foreigner['foreign_table'];
  135.                                 }
  136.                             }
  137.                         }
  138.  
  139.                         // then merge the arrays
  140.                         foreach ($foreign_tables AS $foreign_table) {
  141.                             if (!in_array($foreign_table, $all_tables)) {
  142.                                 $all_tables[] = $foreign_table;
  143.                             }
  144.                         }
  145.                     } // endif there are master tables
  146.                 } // endif auto_layout_internal
  147.  
  148.                 if (isset($auto_layout_internal) || isset($auto_layout_innodb)) {
  149.                     // now generate the coordinates for the schema,
  150.                     // in a clockwise spiral
  151.  
  152.                     $pos_x = 300;
  153.                     $pos_y = 300;
  154.                     $delta = 110;
  155.                     $delta_mult = 1.10;
  156.                     $direction = "right";
  157.                     foreach ($all_tables AS $current_table) {
  158.  
  159.                         // save current table's coordinates
  160.                         $insert_query = 'INSERT INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . ' '
  161.                                       . '(db_name, table_name, pdf_page_number, x, y) '
  162.                                       . 'VALUES (\'' . PMA_sqlAddslashes($db) . '\', \'' . PMA_sqlAddslashes($current_table) . '\',' . $pdf_page_number . ',' . $pos_x . ',' . $pos_y . ')';
  163.                         PMA_query_as_cu($insert_query, FALSE, $query_default_option);
  164.  
  165.                         // compute for the next table
  166.                         switch ($direction) {
  167.                             case 'right':
  168.                                 $pos_x += $delta;
  169.                                 $direction = "down";
  170.                                 $delta *= $delta_mult;
  171.                                 break;
  172.                             case 'down':
  173.                                 $pos_y += $delta;
  174.                                 $direction = "left";
  175.                                 $delta *= $delta_mult;
  176.                                 break;
  177.                             case 'left':
  178.                                 $pos_x -= $delta;
  179.                                 $direction = "up";
  180.                                 $delta *= $delta_mult;
  181.                                 break;
  182.                             case 'up':
  183.                                 $pos_y -= $delta;
  184.                                 $direction = "right";
  185.                                 $delta *= $delta_mult;
  186.                                 break;
  187.                         } // end switch
  188.                     } // end foreach 
  189.                 } // end if some auto-layout to do 
  190.  
  191.                 $chpage = $pdf_page_number;
  192.  
  193.                 break;
  194.  
  195.             case 'edcoord':
  196.                 for ($i = 0; $i < $c_table_rows; $i++) {
  197.                     $arrvalue = 'c_table_' . $i;
  198.                     $arrvalue = $$arrvalue;
  199.                     if (!isset($arrvalue['x']) || $arrvalue['x'] == '') {
  200.                         $arrvalue['x'] = 0;
  201.                     }
  202.                     if (!isset($arrvalue['y']) || $arrvalue['y'] == '') {
  203.                         $arrvalue['y'] = 0;
  204.                     }
  205.                     if (isset($arrvalue['name']) && $arrvalue['name'] != '--') {
  206.                         $test_query = 'SELECT * FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
  207.                                     .   ' WHERE db_name = \'' .  PMA_sqlAddslashes($db) . '\''
  208.                                     .   ' AND   table_name = \'' . PMA_sqlAddslashes($arrvalue['name']) . '\''
  209.                                     .   ' AND   pdf_page_number = ' . $chpage;
  210.                         $test_rs    = PMA_query_as_cu($test_query, FALSE, $query_default_option);
  211.                         if ($test_rs && PMA_DBI_num_rows($test_rs) > 0) {
  212.                             if (isset($arrvalue['delete']) && $arrvalue['delete'] == 'y') {
  213.                                 $ch_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
  214.                                           .   ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
  215.                                           .   ' AND   table_name = \'' . PMA_sqlAddslashes($arrvalue['name']) . '\''
  216.                                           .   ' AND   pdf_page_number = ' . $chpage;
  217.                             } else {
  218.                                 $ch_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . ' '
  219.                                           . 'SET x = ' . $arrvalue['x'] . ', y= ' . $arrvalue['y']
  220.                                           .   ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
  221.                                           .   ' AND   table_name = \'' . PMA_sqlAddslashes($arrvalue['name']) . '\''
  222.                                           .   ' AND   pdf_page_number = ' . $chpage;
  223.                             }
  224.                         } else {
  225.                             $ch_query     = 'INSERT INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . ' '
  226.                                           . '(db_name, table_name, pdf_page_number, x, y) '
  227.                                           . 'VALUES (\'' . PMA_sqlAddslashes($db) . '\', \'' . PMA_sqlAddslashes($arrvalue['name']) . '\',' . $chpage . ',' . $arrvalue['x'] . ',' . $arrvalue['y'] . ')';
  228.                         }
  229.                         PMA_query_as_cu($ch_query, FALSE, $query_default_option);
  230.                     } // end if
  231.                 } // end for
  232.                 break;
  233.             case 'deleteCrap':
  234.                 foreach ($delrow AS $current_row) {
  235.                     $d_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . ' ' . "\n"
  236.                              .   ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' . "\n"
  237.                              .   ' AND   table_name = \'' . PMA_sqlAddslashes($current_row) . '\'' . "\n"
  238.                              .   ' AND   pdf_page_number = ' . $chpage;
  239.                     PMA_query_as_cu($d_query, FALSE, $query_default_option);
  240.                 }
  241.                 break;
  242.         } // end switch
  243.     } // end if (isset($do))
  244.  
  245.     // We will need an array of all tables in this db
  246.     $selectboxall = array('--');
  247.     $alltab_rs    = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', null, PMA_DBI_QUERY_STORE);
  248.     while ($val = @PMA_DBI_fetch_row($alltab_rs)) {
  249.         $selectboxall[] = $val[0];
  250.     }
  251.  
  252.     // Now first show some possibility to choose a page for the pdf
  253.     $page_query = 'SELECT * FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages'])
  254.                 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
  255.     $page_rs    = PMA_query_as_cu($page_query, FALSE, $query_default_option);
  256.  
  257.     if ($page_rs && PMA_DBI_num_rows($page_rs) > 0) {
  258.         ?>
  259. <form method="get" action="pdf_pages.php" name="selpage">
  260.     <fieldset>
  261.      <legend>
  262.     <?php echo $strChoosePage . "\n"; ?>
  263.      </legend>
  264.     <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
  265.     <input type="hidden" name="do" value="choosepage" />
  266.     <select name="chpage" onchange="this.form.submit()">
  267.         <?php
  268.         while ($curr_page = PMA_DBI_fetch_assoc($page_rs)) {
  269.             echo "\n" . '        '
  270.                  . '<option value="' . $curr_page['page_nr'] . '"';
  271.             if (isset($chpage) && $chpage == $curr_page['page_nr']) {
  272.                 echo ' selected="selected"';
  273.             }
  274.             echo '>' . $curr_page['page_nr'] . ': ' . $curr_page['page_descr'] . '</option>';
  275.         } // end while
  276.         echo "\n";
  277.         ?>
  278.     </select>
  279.     <input type="radio" name="action_choose" value="0" id="radio_choose0" checked="checked" style="vertical-align: middle" /><label for="radio_choose0">
  280. <?php echo $strEdit; ?> </label>
  281.     <input type="radio" name="action_choose" value="1" id="radio_choose1"  style="vertical-align: middle" /><label for="radio_choose1">
  282. <?php echo $strDelete; ?> </label>
  283.        <input type="submit" value="<?php echo $strGo; ?>" /><br />
  284.     </fieldset>
  285. </form>
  286.         <?php
  287.     }
  288.     echo "\n";
  289.  
  290.     // Possibility to create a new page:
  291.     ?>
  292. <form method="post" action="pdf_pages.php" name="crpage">
  293.     <fieldset>
  294.      <legend>
  295.     <?php echo $strCreatePage . "\n"; ?>
  296.      </legend>
  297.     <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
  298.     <input type="hidden" name="do" value="createpage" />
  299.     <input type="text" name="newpage" size="20" maxlength="50" />
  300.        <input type="checkbox" name="auto_layout_internal" />
  301.    <?php echo '(' . $strAutomaticLayout . ' / ' . $strInternalRelations . ')' . "\n"; ?>
  302.         <input type="checkbox" name="auto_layout_innodb" />
  303.     <?php echo '(' . $strAutomaticLayout . ' / InnoDB)' . "\n"; ?>
  304.         <input type="submit" value="<?php echo $strGo; ?>" />
  305.     </fieldset>
  306. </form>
  307.     <?php
  308.     // Now if we already have chosen a page number then we should show the
  309.     // tables involved
  310.     if (isset($chpage) && $chpage > 0) {
  311.         echo "\n";
  312.         ?>
  313. <hr />
  314.  
  315. <h2><?php echo $strSelectTables ;?></h2>
  316.  
  317. <?php
  318. $page_query = 'SELECT * FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
  319.             . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
  320.             . ' AND pdf_page_number = ' . $chpage;
  321. $page_rs    = PMA_query_as_cu($page_query, FALSE, $query_default_option);
  322. $array_sh_page = array();
  323. $draginit = '';
  324. $reset_draginit = '';
  325. $i = 0;
  326. while ($temp_sh_page = @PMA_DBI_fetch_assoc($page_rs)) {
  327.     $array_sh_page[] = $temp_sh_page;
  328. }
  329.  
  330. // garvin: Display WYSIWYG-PDF parts?
  331. if ($cfg['WYSIWYG-PDF']) {
  332.     if (!isset($_POST['with_field_names']) && !isset($_POST['showwysiwyg'])) {
  333.         $with_field_names = TRUE;
  334.     }
  335. ?>
  336. <script type="text/javascript" language="javascript" src="./js/dom-drag.js"></script>
  337. <form method="post" action="pdf_pages.php" name="dragdrop">
  338. <input type="button" name="dragdrop" value="<?php echo $strToggleScratchboard; ?>" onclick="ToggleDragDrop('pdflayout');" />
  339.  <input type="button" name="dragdropreset" value="<?php echo $strReset; ?>" onclick="resetDrag();" />
  340. </form>
  341. <div id="pdflayout" class="pdflayout" style="visibility: hidden;">
  342. <?php
  343. foreach ($array_sh_page AS $key => $temp_sh_page) {
  344.     $drag_x = $temp_sh_page['x'];
  345.     $drag_y = $temp_sh_page['y'];
  346.  
  347.     $draginit       .= '    Drag.init(getElement("table_' . $i . '"), null, 0, parseInt(myid.style.width)-2, 0, parseInt(myid.style.height)-5);' . "\n";
  348.     $draginit       .= '    getElement("table_' . $i . '").onDrag = function (x, y) { document.edcoord.elements["c_table_' . $i . '[x]"].value = parseInt(x); document.edcoord.elements["c_table_' . $i . '[y]"].value = parseInt(y) }' . "\n";
  349.     $draginit       .= '    getElement("table_' . $i . '").style.left = "' . $drag_x . 'px";' . "\n";
  350.     $draginit       .= '    getElement("table_' . $i . '").style.top  = "' . $drag_y . 'px";' . "\n";
  351.     $reset_draginit .= '    getElement("table_' . $i . '").style.left = "2px";' . "\n";
  352.     $reset_draginit .= '    getElement("table_' . $i . '").style.top  = "' . (15 * $i) . 'px";' . "\n";
  353.     $reset_draginit .= '    document.edcoord.elements["c_table_' . $i . '[x]"].value = "2"' . "\n";
  354.     $reset_draginit .= '    document.edcoord.elements["c_table_' . $i . '[y]"].value = "' . (15 * $i) . '"' . "\n";
  355.  
  356.     $local_query = 'SHOW FIELDS FROM '
  357.                  .  PMA_backquote($temp_sh_page['table_name'] )
  358.                 . ' FROM ' . PMA_backquote($db);
  359.     $fields_rs = PMA_DBI_query($local_query);
  360.     unset($local_query);
  361.     $fields_cnt = PMA_DBI_num_rows($fields_rs);
  362.  
  363.     echo '<div id="table_' . $i . '" class="pdflayout_table"><u>' . $temp_sh_page['table_name'] . '</u>';
  364.     if (isset($with_field_names)) {
  365.         while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
  366.             echo '<br />' . htmlspecialchars($row['Field']) . "\n";
  367.         }
  368.     }
  369.     echo '</div>' . "\n";
  370.     PMA_DBI_free_result($fields_rs);
  371.     unset($fields_rs);
  372.  
  373.     $i++;
  374. }
  375. ?>
  376. </div>
  377. <script type="text/javascript" language="javascript">
  378. //<![CDATA[
  379. function init() {
  380.     refreshLayout();
  381.     myid = getElement('pdflayout');
  382.     <?php echo $draginit; ?>
  383. }
  384.  
  385. function resetDrag() {
  386.     <?php echo $reset_draginit; ?>
  387. }
  388. //]]>
  389. </script>
  390. <?php
  391. } // end if WYSIWYG-PDF
  392. ?>
  393.  
  394. <form method="post" action="pdf_pages.php" name="edcoord">
  395.     <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
  396.     <input type="hidden" name="chpage" value="<?php echo $chpage; ?>" />
  397.     <input type="hidden" name="do" value="edcoord" />
  398.     <table border="0">
  399.     <tr>
  400.         <th><?php echo $strTable; ?></th>
  401.         <th><?php echo $strDelete; ?></th>
  402.         <th>X</th>
  403.         <th>Y</th>
  404.     </tr>
  405.         <?php
  406.         if (isset($ctable)) {
  407.             unset($ctable);
  408.         }
  409.  
  410.  
  411.         $i = 0;
  412.         $odd_row = true;
  413.         foreach ($array_sh_page AS $dummy_sh_page => $sh_page) {
  414.             $_mtab       = $sh_page['table_name'];
  415.             $tabExist[$_mtab] = FALSE;
  416.             echo "\n" . '    <tr class="';
  417.             if ($odd_row) {
  418.                 echo 'odd';
  419.             } else {
  420.                 echo 'even';
  421.             }
  422.             echo '">';
  423.             $odd_row != $odd_row;
  424.             echo "\n" . '        <td>'
  425.                  . "\n" . '            <select name="c_table_' . $i . '[name]">';
  426.             foreach ($selectboxall AS $key => $value) {
  427.                 echo "\n" . '                <option value="' . $value . '"';
  428.                 if ($value == $sh_page['table_name']) {
  429.                     echo ' selected="selected"';
  430.                     $tabExist[$_mtab] = TRUE;
  431.                 }
  432.                 echo '>' . $value . '</option>';
  433.             } // end while
  434.             echo "\n" . '            </select>'
  435.                  . "\n" . '        </td>';
  436.             echo "\n" . '        <td>'
  437.                  . "\n" . '            <input type="checkbox" name="c_table_' . $i . '[delete]" value="y" />' . $strDelete;
  438.             echo "\n" . '        </td>';
  439.             echo "\n" . '        <td>'
  440.                  . "\n" . '            <input type="text" ' . ($cfg['WYSIWYG-PDF'] ? 'onchange="dragPlace(' . $i . ', \'x\', this.value)"' : '') . ' name="c_table_' . $i . '[x]" value="' . $sh_page['x'] . '" />';
  441.             echo "\n" . '        </td>';
  442.             echo "\n" . '        <td>'
  443.                  . "\n" . '            <input type="text" ' . ($cfg['WYSIWYG-PDF'] ? 'onchange="dragPlace(' . $i . ', \'y\', this.value)"' : '') . ' name="c_table_' . $i . '[y]" value="' . $sh_page['y'] . '" />';
  444.             echo "\n" . '        </td>';
  445.             echo "\n" . '    </tr>';
  446.             $i++;
  447.         } // end while
  448.         // Do one more empty row
  449.         echo "\n" . '    <tr class="';
  450.         if ($odd_row) {
  451.             echo 'odd';
  452.         } else {
  453.             echo 'even';
  454.         }
  455.         $odd_row != $odd_row;
  456.         echo '">';
  457.         echo "\n" . '        <td>'
  458.              . "\n" . '            <select name="c_table_' . $i . '[name]">';
  459.         foreach ($selectboxall AS $key => $value) {
  460.             echo "\n" . '                <option value="' . $value . '">' . $value . '</option>';
  461.         }
  462.         echo "\n" . '            </select>'
  463.              . "\n" . '        </td>';
  464.         echo "\n" . '        <td>'
  465.              . "\n" . '            <input type="checkbox" name="c_table_' . $i . '[delete]" value="y" />' . $strDelete;
  466.         echo "\n" . '        </td>';
  467.         echo "\n" . '        <td>'
  468.              . "\n" . '            <input type="text" name="c_table_' . $i . '[x]" value="' . (isset($sh_page['x'])?$sh_page['x']:'') . '" />';
  469.         echo "\n" . '        </td>';
  470.         echo "\n" . '        <td>'
  471.              . "\n" . '            <input type="text" name="c_table_' . $i . '[y]" value="' . (isset($sh_page['y'])?$sh_page['y']:'') . '" />';
  472.         echo "\n" . '        </td>';
  473.         echo "\n" . '    </tr>';
  474.         echo "\n" . '    </table>' . "\n";
  475.  
  476.         echo "\n" . '    <input type="hidden" name="c_table_rows" value="' . ($i + 1) . '" />';
  477.         echo ($cfg['WYSIWYG-PDF'] ? "\n" . '    <input type="hidden" name="showwysiwyg" value="' . ((isset($showwysiwyg) && $showwysiwyg == '1') ? '1' : '0') . '" />' : '');
  478.         echo "\n" . '    <input type="checkbox" name="with_field_names" ' . (isset($with_field_names) ? 'checked="checked"' : ''). ' />' . $strColumnNames . '<br />';
  479.         echo "\n" . '    <input type="submit" value="' . $strSave . '" />';
  480.         echo "\n" . '</form>' . "\n\n";
  481.     } // end if
  482.  
  483.     //  Check if there are tables that need to be deleted,
  484.     //  if there are, ask the user for allowance
  485.     $_strtrans  = '';
  486.     $_strname   = '';
  487.     $shoot      = FALSE;
  488.     if (!empty($tabExist) && is_array($tabExist)) {
  489.         foreach ($tabExist AS $key => $value) {
  490.             if (!$value) {
  491.                 $_strtrans  .= '<input type="hidden" name="delrow[]" value="' . $key . '" />' . "\n";
  492.                 $_strname   .= '<li>' . $key . '</li>' . "\n";
  493.                 $shoot       = TRUE;
  494.             }
  495.         }
  496.         if ($shoot) {
  497.             echo '<form action="pdf_pages.php" method="post">' . "\n"
  498.                . PMA_generate_common_hidden_inputs($db, $table)
  499.                . '<input type="hidden" name="do" value="deleteCrap" />' . "\n"
  500.                . '<input type="hidden" name="chpage" value="' . $chpage . '" />' . "\n"
  501.                . $strDelOld
  502.                . '<ul>' . "\n"
  503.                . $_strname
  504.                . '</ul>' . "\n"
  505.                . $_strtrans
  506.                . '<input type="submit" value="' . $strGo . '" />' . "\n"
  507.                . '</form>';
  508.         }
  509.     }
  510.     //    ------------------------------------
  511.     //    d i s p l a y   p d f    s c h e m a
  512.     //    ------------------------------------
  513.  
  514.     if (isset($do)
  515.     && ($do == 'edcoord'
  516.        || ($do == 'choosepage' && isset($chpage))
  517.        || ($do == 'createpage' && isset($chpage)))) {
  518.         ?>
  519. <form method="post" action="pdf_schema.php" name="pdfoptions">
  520.     <?php echo PMA_generate_common_hidden_inputs($db); ?>
  521.     <input type="hidden" name="pdf_page_number" value="<?php echo $chpage; ?>" />
  522.  
  523.     <?php echo '<br /><b>' . $strDisplayPDF . '</b>'; ?>: <br />
  524.     <input type="checkbox" name="show_grid" id="show_grid_opt" /><label for="show_grid_opt"><?php echo $strShowGrid; ?></label><br />
  525.     <input type="checkbox" name="show_color" id="show_color_opt" checked="checked" /><label for="show_color_opt"><?php echo $strShowColor; ?></label><br />
  526.     <input type="checkbox" name="show_table_dimension" id="show_table_dim_opt" /><label for="show_table_dim_opt"><?php echo $strShowTableDimension; ?></label><br />
  527.     <input type="checkbox" name="all_tab_same_wide" id="all_tab_same_wide" /><label for="all_tab_same_wide"><?php echo $strAllTableSameWidth; ?></label><br />
  528.     <input type="checkbox" name="with_doc" id="with_doc" checked="checked" /><label for="with_doc"><?php echo $strDataDict; ?></label>
  529.     <br />
  530.     <label for="orientation_opt"><?php echo $strShowDatadictAs; ?></label>
  531.     <select id="orientation_opt" name="orientation" <?php echo ($cfg['WYSIWYG-PDF'] ? 'onchange="refreshDragOption(\'pdflayout\');"' : ''); ?>>
  532.         <option value="L"><?php echo $strLandscape;?></option>
  533.         <option value="P"><?php echo $strPortrait;?></option>
  534.     </select><br />
  535.  
  536.     <label for="paper_opt"><?php echo $strPaperSize; ?></label>
  537.     <select id="paper_opt" name="paper" <?php echo ($cfg['WYSIWYG-PDF'] ? 'onchange="refreshDragOption(\'pdflayout\');"' : ''); ?>>
  538. <?php
  539.         foreach ($cfg['PDFPageSizes'] AS $key => $val) {
  540.             echo '<option value="' . $val . '"';
  541.             if ($val == $cfg['PDFDefaultPageSize']) {
  542.                 echo ' selected="selected"';
  543.             }
  544.             echo ' >' . $val . '</option>' . "\n";
  545.         }
  546. ?>
  547.     </select><br />
  548.       <input type="submit" value="<?php echo $strGo; ?>" />
  549. </form>
  550. <?php
  551.         if ((isset($showwysiwyg) && $showwysiwyg == '1')) {
  552. ?>
  553. <script type="text/javascript" language="javascript">
  554. //<![CDATA[
  555. ToggleDragDrop('pdflayout');
  556. //]]>
  557. </script>
  558. <?php
  559.         }
  560.     } // end if
  561. } // end if ($cfgRelation['pdfwork'])
  562.  
  563.  
  564. /**
  565.  * Displays the footer
  566.  */
  567. echo "\n";
  568. require_once('./libraries/footer.inc.php');
  569. ?>
  570.